package net.jlibrary.common.project.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import net.jlibrary.common.core.annotation.CodeGenComment;
import net.jlibrary.common.core.annotation.Compositor;
import net.jlibrary.common.core.annotation.SearchCondition;
import net.jlibrary.common.core.annotation.SearchField;
import net.jlibrary.common.core.entity.BaseObject;

@Entity(name = "tab_systemconfig")
@Compositor
public class SystemConfig extends BaseObject {
	private static final long serialVersionUID = -6515464616539976238L;
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@SearchField(value = "id", condition = SearchCondition.EQUAL)
	private Long id;
	@Column(length = 50)
	@SearchField(value = "skey", condition = SearchCondition.EQUAL)
	@CodeGenComment(value = "关键字", viewList = true, viewSearch = true, viewText = true, required = true)
	private String skey;// 关键字，规则：服务器名.key或all.key
	@Column(length = 200)
	@CodeGenComment(value = "描述")
	private String sdescription;// 描述
	@Column(length = 1000)
	@CodeGenComment(value = "值", viewList = true, required = true)
	private String svalue;// 值
	@CodeGenComment(value = "是否加密", viewList = true, required = true)
	private boolean encrypt;//是否加密
	@Column(updatable = false)
	@Temporal(TemporalType.TIMESTAMP)
	@CodeGenComment(value = "创建时间", viewList = true)
	private Date createdate;
	@Temporal(TemporalType.TIMESTAMP)
	private Date lastdate;
	public Long getId() {
		return id;
	}
	@Override
	public Serializable getPrimaryKey() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getSkey() {
		return skey;
	}
	public void setSkey(String skey) {
		this.skey = skey;
	}
	public String getSdescription() {
		return sdescription;
	}
	public void setSdescription(String sdescription) {
		this.sdescription = sdescription;
	}
	public String getSvalue() {
		return svalue;
	}
	public void setSvalue(String svalue) {
		this.svalue = svalue;
	}
	public boolean isEncrypt() {
		return encrypt;
	}
	public void setEncrypt(boolean encrypt) {
		this.encrypt = encrypt;
	}
	public Date getCreatedate() {
		return createdate;
	}
	public void setCreatedate(Date createdate) {
		this.createdate = createdate;
	}
	public Date getLastdate() {
		return lastdate;
	}
	public void setLastdate(Date lastdate) {
		this.lastdate = lastdate;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SystemConfig other = (SystemConfig) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
}
